/*
 * $Id: Named.h,v 1.2 2006-02-07 06:02:35 bacon Exp $
 */

#ifndef _XPP_NAMED_CLASS_
#define _XPP_NAMED_CLASS_

#include <xp/types.h>
#include <xp/macros.h>
#include <xp/bas/string.h>
#include <xp/bas/assert.h>

namespace xpp 
{

	class Named 
	{
	public:

		Named (const xp_char_t* name = XP_TEXT(""))
		{
			xp_assert (name != XP_NULL);
			// WARNING: a long name can be truncated
			xp_strxcpy (name_buf, sizeof(name_buf), name);
		}
		virtual ~Named () {}

		xp_char_t* name ()
		{
			return name_buf;
		}

		const xp_char_t* name () const
		{
			return name_buf;
		}

		void setName (const xp_char_t* name)
		{
			xp_assert (name != XP_NULL);
			// WARNING: a long name can be truncated
			xp_strxcpy (name_buf, sizeof(name_buf), name);
		}

		bool isNamed (const xp_char_t* n) const
		{
			return xp_strcmp (name_buf, n) == 0;
		}

		enum {
			MAX_NAME_LEN = 64
		};

	protected:
		xp_char_t name_buf[MAX_NAME_LEN + 1]; 
	};

}

#endif
